// modules/video/video.controller.ts

import { Provide, Inject } from '@midwayjs/core';
import { CoolController, BaseController, BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Column, Entity, PrimaryGeneratedColumn, Repository, CreateDateColumn } from 'typeorm';

/**
 * 视频表
 */
@Entity('video')
export class VideoEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'int', comment: '分类ID' })
  categoryId: number;

  @Column({ type: 'varchar', length: 255, comment: '封面URL' })
  cover: string;

  @Column({ type: 'varchar', length: 128, comment: '标题' })
  title: string;

  @Column({ type: 'varchar', length: 255, comment: '视频文件URL' })
  videoUrl: string;

  @Column({ type: 'text', nullable: true, comment: '描述' })
  description: string;

  @Column({ type: 'int', default: 0, comment: '评论数' })
  comments: number;

  @Column({ type: 'int', default: 0, comment: '点赞数' })
  likes: number;

  @Column({ type: 'int', default: 0, comment: '分享数' })
  shares: number;

  @CreateDateColumn({ type: 'timestamp', comment: '创建时间' })
  createTime: Date;

  // 新增：所属分站ID
  @Column({ type: 'int', comment: '所属分站ID' })
  siteId: number;  // 分站ID
}

/**
 * 视频控制器
 */
@Provide()
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: VideoEntity,
})
export class VideoController extends BaseController {

  // 如需自定义接口可在此扩展
  // @Post('/custom')
  // async custom(@Body() body) {
  //   return this.ok(await this.videoService.someMethod(body));
  // }
}
